# encoding=utf-8
# @Author: Winter
# @Time: 2017/12/13 11:21

import jieba.analyse as analyse


# 基于 TF-IDF 算法的关键词抽取
lines = open("西游记.txt", 'rb').read()
# print(" ".join(analyse.extract_tags(lines, topK=20, withWeight=False, allowPOS=())))


# 基于 TextRank 算法的关键词抽取
print("  ".join(analyse.textrank(lines, topK=20, withWeight=False, allowPOS=('ns', 'n', 'vn', 'v'))))


